Minimal DASK distributed example with python asyncio

Start a scheduler und worker in a shell:

dask scheduler --host 127.0.0.1 --port 8786 --dashboard-address 127.0.0.1:8787 --no-jupyter &
dask worker tcp://127.0.0.1:8786 &

Und hier das sample python script:

import asyncio
from time import sleep
from distributed import Client

def mytask(payload):
    sleep(10)
    return payload

async def amain():
    async with Client("127.0.0.1:8786", asynchronous=True) as client:
        result = await client.submit(mytask, 'mypayload')
        print(result)

def main():
    asyncio.run(amain())

if __name__ == '__main__':
    main()